/*
 * @Descripttion: 
 * @Author: liuYaoYu
 * @Date: 2021-12-18 18:00:26
 * @LastEditors: liuYaoYu
 * @LastEditTime: 2021-12-18 18:24:20
 */
package main
import (
	"fmt"
)


func BinaryFind( arr *[8]int,leftIndex int,rightIndex int,findVal int ) {
	if leftIndex>rightIndex{
		fmt.Println("找不到")
		return
	}
	middle:=(leftIndex+rightIndex)/2;
	if (*arr)[middle]>findVal{
		BinaryFind(arr,leftIndex,middle-1,findVal)
	}else if (*arr)[middle]<findVal{
		BinaryFind(arr,middle+1,rightIndex,findVal)
	}else{
		// 找到了
		fmt.Printf("找到了下表为%v\n",middle)
	}
}

func main(){
	arr :=[8]int{1,2,3,4,5,6,7,8}
	BinaryFind(&arr,0,len(arr)-1,8)
}